package com.example.spring8.converter;

import org.springframework.cglib.core.Converter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateCinverter implements Converter<String, Date> {

    @Override
    public Object convert(Object o, Class aClass, Object o1) {
        if("".equals(s)){
            return null;
        }
        Date parse=null;
        DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            parse = dateFormat.parse(s);
        }catch (Exception e){
            e.printStackTrace();
        }
        return parse;
    }
}
